'''
Author: linxuan
Date: 2022-07-17 13:24:37
Description: 使用selenium 爬去zora
FilePath: /stealer/src/zora_co.py
'''
import json
from pprint import pprint
import time
import datetime
from typing import List
from selenium.common import exceptions
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement

from upload import upload


def get_art_list(type: str) -> list:
    '''
        audio和video的网页结构有所不同，因此用参数type进行区分
    '''
    url = f'https://zora.co/explore?mediaTypes%5B0%5D={type}'
    web = Chrome()
    web.get(url)
    # 增大首页条目
    for i in range(10):
        web.execute_script('window.scrollTo(0, document.body.scrollHeight)')
        time.sleep(3)
    time.sleep(3)
    if type == 'audio':
        eles = web.find_elements(By.XPATH, '//*[@id="__next"]/div/div/div[3]/div[3]/div/div[1]/div/a[1]')
    elif type == 'video':
        eles = web.find_elements(By.XPATH, '/html/body/div[1]/div/div/div[3]/div[3]/div/div[1]/div/a[1]')
    urls = []
    for item in eles:
        urls.append(item.get_attribute('href'))
    web.close()
    return urls


def get_audio_info(url: str, web: Chrome) -> dict:
    web.get(url)
    params = dict()

    def get(xpath: str) -> WebElement:
        return web.find_element(By.XPATH, xpath)
    params['name'] = get('//*[@id="__next"]/div[1]/div/div[2]/main/h2').text
    params['discription'] = get('//*[@id="__next"]/div[1]/div/div[2]/main/section').text
    params['content_url'] = get('//*[@id="__next"]/div[1]/div/div[1]/audio').get_attribute('src')
    # //*[@id="__next"]/div[1]/div/div[2]/main/div[4]/div[2]/div[2]/span[2]
    try:
        price = get('//*[@id="__next"]/div[1]/div/div[2]/aside/div/div/div/div[2]').text
        price = price.split(' ')[0]
        price = float(price)
    except:
        price = -1
    params['price'] = price
    amount = params['name'].split('/')[-1]
    try:
        amount = int(amount)
    except:
        amount = -1
    params['amount'] = amount

    # 获取不一定有的properties
    properties = web.find_elements(By.XPATH, '//*[@id="__next"]/div[1]/div/div[2]/main/div[3]/div[2]/div')
    for item in properties:
        try:
            key = item.find_element(By.XPATH, './span[1]').text
            value = item.find_element(By.XPATH, './span[2]').text
            if key == 'Artist':
                params['author'] = value
            elif key == 'Album':
                params['collection'] = value
            elif key == 'Data':
                params['date'] = value[:10]
        except:
            continue
    if 'date' not in params:
        params['date'] = datetime.datetime.now().strftime('%Y-%m-%d')
    if 'author' not in params:
        params['author'] = 'Unknown'
    if 'collection' not in params:
        params['collection'] = params['name']
    # 获取可能位置变化的details
    detials = web.find_elements(By.XPATH, '//*[@id="__next"]/div[1]/div/div[2]/main/div[4]/div[2]/div')
    for item in detials:
        try:
            key = item.find_element(By.XPATH, './span[1]').text
            span = item.find_element(By.XPATH, './span[2]')
            if key == 'Contract Address':
                params['contract_address'] = span.text
                params['contract_address_link'] = span.find_element(By.XPATH, './a').get_attribute('href')
            elif key == 'Token ID':
                params['token_id'] = span.text
            elif key == 'Blockchain':
                params['blockchain'] = span.text
        except:
            continue
    params['platform'] = 'zora'
    params['origin_link'] = url
    params['type'] = 'audio'
    return params


def get_video_info(url: str, web: Chrome) -> dict:
    web.get(url)
    params = dict()

    def get(xpath: str) -> WebElement:
        return web.find_element(By.XPATH, xpath)

    params['content_url'] = get('//*[@id="__next"]/div[1]/div/div[1]/div/video').get_attribute('src')
    params['name'] = get('//*[@id="__next"]/div[1]/div/div[2]/main/h2').text
    params['discription'] = get('//*[@id="__next"]/div[1]/div/div[2]/main/section').text
    try:
        price = get('//*[@id="__next"]/div[1]/div/div[2]/aside/div/div/div/div[2]').text
        price = price.split(' ')[0]
        price = float(price)
    except:
        price = -1
    params['price'] = price
    try:
        amount = int(params['name'].split('/')[-1])
    except:
        amount = -1
    params['amount'] = amount

    properties = web.find_elements(By.XPATH, '//*[@id="__next"]/div[1]/div/div[2]/main/div[3]/div[2]/div')
    for item in properties:
        try:
            key = item.find_element(By.XPATH, './span[1]').text
            value = item.find_element(By.XPATH, './span[2]').text
            if key == 'Artist':
                params['author'] = value
            elif key == 'Album':
                params['collection'] = value
            elif key == 'Data':
                params['date'] = value[:10]
        except:
            continue
    if 'date' not in params:
        params['date'] = datetime.datetime.now().strftime('%Y-%m-%d')
    if 'author' not in params:
        params['author'] = 'Unknown'
    if 'collection' not in params:
        params['collection'] = params['name']
    # 获取可能位置变化的details
    detials = web.find_elements(By.XPATH, '//*[@id="__next"]/div[1]/div/div[2]/main/div[4]/div[2]/div')
    for item in detials:
        try:
            key = item.find_element(By.XPATH, './span[1]').text
            span = item.find_element(By.XPATH, './span[2]')
            if key == 'Contract Address':
                params['contract_address'] = span.text
                params['contract_address_link'] = span.find_element(By.XPATH, './a').get_attribute('href')
            elif key == 'Token ID':
                params['token_id'] = span.text
            elif key == 'Blockchain':
                params['blockchain'] = span.text
        except:
            continue
    params['platform'] = 'zora'
    params['origin_link'] = url
    params['type'] = 'video'
    return params


def main():
    # urls = get_art_list('audio')
    # print(len(urls), urls)
    urls = [
        'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/205', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/197', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/193', 'https://zora.co/collections/0x59fB3c7934dDeB31B3080814f5bbA0C5563C34a2/14', 'https://zora.co/collections/zora/20461', 'https://zora.co/collections/0x2B5426A5B98a3E366230ebA9f95a24f09Ae4a584/119', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/176', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/164', 'https://zora.co/collections/0x2F04d6F5881A0D49B870bEa2D03853DF7EB46101/1020847100762815390390123822295304634391', 'https://zora.co/collections/0xAB80184B3Bba02e975B6494d570232fB6c6973f1/680564733841876926926749214863536422959', 'https://zora.co/collections/0x59fB3c7934dDeB31B3080814f5bbA0C5563C34a2/10', 'https://zora.co/collections/0x59fB3c7934dDeB31B3080814f5bbA0C5563C34a2/9', 'https://zora.co/collections/0x59fB3c7934dDeB31B3080814f5bbA0C5563C34a2/8', 'https://zora.co/collections/0x59fB3c7934dDeB31B3080814f5bbA0C5563C34a2/7', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/138', 'https://zora.co/collections/0xAB80184B3Bba02e975B6494d570232fB6c6973f1/680564733841876926926749214863536422956', 'https://zora.co/collections/0x59fB3c7934dDeB31B3080814f5bbA0C5563C34a2/5', 'https://zora.co/collections/0x59fB3c7934dDeB31B3080814f5bbA0C5563C34a2/6', 'https://zora.co/collections/0x59fB3c7934dDeB31B3080814f5bbA0C5563C34a2/4', 'https://zora.co/collections/0x59fB3c7934dDeB31B3080814f5bbA0C5563C34a2/3', 'https://zora.co/collections/0x59fB3c7934dDeB31B3080814f5bbA0C5563C34a2/1', 'https://zora.co/collections/zora/9571', 'https://zora.co/collections/0x2F04d6F5881A0D49B870bEa2D03853DF7EB46101/53', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/145', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/144', 'https://zora.co/collections/zora/19011', 'https://zora.co/collections/zora/18849', 'https://zora.co/collections/zora/8758', 'https://zora.co/collections/zora/7986', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/133', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/146', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/145', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/144', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/143', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/142', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/141', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/140', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/139', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/138', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/137', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/136', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/135', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/134', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/133', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/132', 'https://zora.co/collections/zora/18534', 'https://zora.co/collections/zora/9990', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/113', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/116', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/117', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/115', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/111', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/114', 'https://zora.co/collections/0xdC17fED95041881d56482aC5Ff1deC958C033E33/9', 'https://zora.co/collections/0xdC17fED95041881d56482aC5Ff1deC958C033E33/8', 'https://zora.co/collections/0xdC17fED95041881d56482aC5Ff1deC958C033E33/7', 'https://zora.co/collections/0xdC17fED95041881d56482aC5Ff1deC958C033E33/6', 'https://zora.co/collections/0xdC17fED95041881d56482aC5Ff1deC958C033E33/5', 'https://zora.co/collections/0xdC17fED95041881d56482aC5Ff1deC958C033E33/4', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/102', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/109', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/110', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/106', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/107', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/105', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/104', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/103', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/108', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/102', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/101', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/100', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/99', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/98', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/97', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/96', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/95', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/94', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/93', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/92', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/91', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/96', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/81', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/87', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/80', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/79', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/75', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/71', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/77', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/76', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/73', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/74', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/72', 'https://zora.co/collections/0x6eB95f70730DDECe8539fe2aed9D1864Bab85145/10', 'https://zora.co/collections/0x6eB95f70730DDECe8539fe2aed9D1864Bab85145/9', 'https://zora.co/collections/0x6eB95f70730DDECe8539fe2aed9D1864Bab85145/8', 'https://zora.co/collections/0x6eB95f70730DDECe8539fe2aed9D1864Bab85145/7', 'https://zora.co/collections/0x6eB95f70730DDECe8539fe2aed9D1864Bab85145/6', 'https://zora.co/collections/0x6eB95f70730DDECe8539fe2aed9D1864Bab85145/5', 'https://zora.co/collections/0x6eB95f70730DDECe8539fe2aed9D1864Bab85145/4', 'https://zora.co/collections/0x6eB95f70730DDECe8539fe2aed9D1864Bab85145/3', 'https://zora.co/collections/0x6eB95f70730DDECe8539fe2aed9D1864Bab85145/2', 'https://zora.co/collections/0x6eB95f70730DDECe8539fe2aed9D1864Bab85145/1', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/72', 'https://zora.co/collections/0x8B7882A7c6C9CA8aA95a523BE4f99224e8E16CAA/680564733841876926926749214863536422949', 'https://zora.co/collections/zora/6087', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/78', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/62', 'https://zora.co/collections/zora/9712', 'https://zora.co/collections/zora/6673', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/58', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/56', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/55', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/54', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/53', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/52', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/51', 'https://zora.co/collections/zora/8773', 'https://zora.co/collections/0xAB80184B3Bba02e975B6494d570232fB6c6973f1/7', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/60', 'https://zora.co/collections/0x6Ea5C4004f3537765c7630C70DbC7852953EEFDD/1', 'https://zora.co/collections/0xE761cCd2Ef51FfDfF438ABd07b84310DD52bb056/680564733841876926926749214863536422936', 'https://zora.co/collections/zora/7186', 'https://zora.co/collections/zora/6311', 'https://zora.co/collections/zora/7374', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/47', 'https://zora.co/collections/zora/8660', 'https://zora.co/collections/zora/8930', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/50', 'https://zora.co/collections/zora/10482', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/43', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/39', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/38', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/47', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/34', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/32', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/50',
        'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/49', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/41', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/48', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/45', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/42', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/46', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/44', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/33', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/36', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/37', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/40', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/35', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/31', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/16', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/22', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/19', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/27', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/15', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/26', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/24', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/30', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/20', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/29', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/23', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/21', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/17', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/28', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/18', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/12', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/25', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/13', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/14', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/11', 'https://zora.co/collections/zora/8649', 'https://zora.co/collections/zora/7848', 'https://zora.co/collections/zora/217', 'https://zora.co/collections/zora/9764', 'https://zora.co/collections/zora/9697', 'https://zora.co/collections/zora/9542', 'https://zora.co/collections/zora/6032', 'https://zora.co/collections/0x5e8030378132067531aDBc7e358d41c795FD4eA5/2', 'https://zora.co/collections/zora/9417', 'https://zora.co/collections/zora/2216', 'https://zora.co/collections/0x5e8030378132067531aDBc7e358d41c795FD4eA5/1', 'https://zora.co/collections/zora/8875', 'https://zora.co/collections/zora/8823', 'https://zora.co/collections/0x5BBC122E437A0F418b64454De76A431658C5162B/5', 'https://zora.co/collections/0x5BBC122E437A0F418b64454De76A431658C5162B/4', 'https://zora.co/collections/0x5BBC122E437A0F418b64454De76A431658C5162B/1', 'https://zora.co/collections/0x5BBC122E437A0F418b64454De76A431658C5162B/3', 'https://zora.co/collections/0x5BBC122E437A0F418b64454De76A431658C5162B/0', 'https://zora.co/collections/zora/8045', 'https://zora.co/collections/zora/7486', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/202', 'https://zora.co/collections/zora/10118', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/198', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/195', 'https://zora.co/collections/zora/10195', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/55', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/188', 'https://zora.co/collections/0x95302A13f7A9E0301d7Dd5F65e3152b97Bb52DE5/13', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/112', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/192', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/150', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/97', 'https://zora.co/collections/zora/8616', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/92', 'https://zora.co/collections/zora/17638', 'https://zora.co/collections/zora/9363', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/61', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/182', 'https://zora.co/collections/zora/8847', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/152', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/157', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/172', 'https://zora.co/collections/zora/19394', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/168', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/130', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/140', 'https://zora.co/collections/0x98174c289b022e1b5f57485A814eDf93e9f0d94f/1', 'https://zora.co/collections/zora/19187', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/159', 'https://zora.co/collections/0x813740BEbB0CAFDFB9474723757a31BA588753dc/7', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/149', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/161', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/125', 'https://zora.co/collections/zora/9567', 'https://zora.co/collections/zora/9548', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/160', 'https://zora.co/collections/0x6688Ee4E6e17a9cF88A13Da833b011E64C2B4203/70', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/151', 'https://zora.co/collections/zora/5662', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/119', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/79', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/129', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/136', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/128', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/106', 'https://zora.co/collections/zora/8822', 'https://zora.co/collections/zora/5746', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/76', 'https://zora.co/collections/zora/9610', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/123', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/20', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/121', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/117', 'https://zora.co/collections/0x19b703f65aA7E1E775BD06c2aa0D0d08c80f1C45/4908', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/116', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/111', 'https://zora.co/collections/0x35680759a7C0F4E2F1ec2e08B4edF24d16aF0F79/131', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/115', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/113', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/107', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/110', 'https://zora.co/collections/zora/8802', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/38', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/21', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/105', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/104', 'https://zora.co/collections/zora/6388', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/90', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/101', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/100', 'https://zora.co/collections/0x6688Ee4E6e17a9cF88A13Da833b011E64C2B4203/9', 'https://zora.co/collections/0xdC17fED95041881d56482aC5Ff1deC958C033E33/2', 'https://zora.co/collections/0x813740BEbB0CAFDFB9474723757a31BA588753dc/12', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/93', 'https://zora.co/collections/0x6688Ee4E6e17a9cF88A13Da833b011E64C2B4203/7', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/91', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/86', 'https://zora.co/collections/0xdC17fED95041881d56482aC5Ff1deC958C033E33/3', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/63', 'https://zora.co/collections/0x6688Ee4E6e17a9cF88A13Da833b011E64C2B4203/73', 'https://zora.co/collections/0x6688Ee4E6e17a9cF88A13Da833b011E64C2B4203/33', 'https://zora.co/collections/zora/9517', 'https://zora.co/collections/0x6688Ee4E6e17a9cF88A13Da833b011E64C2B4203/27', 'https://zora.co/collections/0x6688Ee4E6e17a9cF88A13Da833b011E64C2B4203/80', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/24', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/49', 'https://zora.co/collections/0x6688Ee4E6e17a9cF88A13Da833b011E64C2B4203/28', 'https://zora.co/collections/zora/9660', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/81', 'https://zora.co/collections/0x0bC2A24ce568DAd89691116d5B34DEB6C203F342/45', 'https://zora.co/collections/0x6688Ee4E6e17a9cF88A13Da833b011E64C2B4203/41']
    opt = Options()
    opt.add_argument('--start-maximized')
    path = '/resources/zora.music/'[1:]
    web = Chrome(options=opt)
    # print(len(urls), urls)
    for index in range(len(urls)):
        try:
            print(index, '-', urls[index])
            params = get_audio_info(urls[index], web)

            try:
                with open(f'{path}{index}.json', 'w') as f:
                    json.dump(params, f)
                    print(f'{index} save success')
            except:
                print(f'{index} save faild')
        except Exception as e:
            print(f'{index} error', e.args[0])
        time.sleep(3)

        # ok, err = upload(params)
        # if ok == 200:
        #     print(f'{index} success')
        # else:
        #     print(f'{index} upload faild')

        # params存本地json文件


if __name__ == "__main__":
    main()
